package com.yishuai.ollamatest1.dto;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class ChatResponse {
    private String model;
    private String createdAt;
    private boolean done;
    private String doneReason;
    private long totalDuration;
    private long loadDuration;
    private int promptEvalCount;
    private long promptEvalDuration;
    private int evalCount;
    private long evalDuration;
    private Message message;

    // 添加带错误消息的构造函数，方便错误处理
    public ChatResponse(String errorMessage) {
        this.message = new Message("assistant", errorMessage);
        this.done = true;
        this.doneReason = "error";
    }

    public ChatResponse() {}
    
    public void setMessageContent(String content) {
        this.message = new Message("assistant", content);
    }

    public static class Message {
        private String role;
        private String content;

        public Message() {}
        
        public Message(String role, String content) {
            this.role = role;
            this.content = content;
        }

        public String getRole() { return role; }
        public void setRole(String role) { this.role = role; }

        public String getContent() { return content; }
        public void setContent(String content) { this.content = content; }
    }

    // getters / setters
    public String getModel() { return model; }
    public void setModel(String model) { this.model = model; }

    public String getCreatedAt() { return createdAt; }
    public void setCreatedAt(String createdAt) { this.createdAt = createdAt; }

    public boolean isDone() { return done; }
    public void setDone(boolean done) { this.done = done; }

    public String getDoneReason() { return doneReason; }
    public void setDoneReason(String doneReason) { this.doneReason = doneReason; }

    public long getTotalDuration() { return totalDuration; }
    public void setTotalDuration(long totalDuration) { this.totalDuration = totalDuration; }

    public long getLoadDuration() { return loadDuration; }
    public void setLoadDuration(long loadDuration) { this.loadDuration = loadDuration; }

    public int getPromptEvalCount() { return promptEvalCount; }
    public void setPromptEvalCount(int promptEvalCount) { this.promptEvalCount = promptEvalCount; }

    public long getPromptEvalDuration() { return promptEvalDuration; }
    public void setPromptEvalDuration(long promptEvalDuration) { this.promptEvalDuration = promptEvalDuration; }

    public int getEvalCount() { return evalCount; }
    public void setEvalCount(int evalCount) { this.evalCount = evalCount; }

    public long getEvalDuration() { return evalDuration; }
    public void setEvalDuration(long evalDuration) { this.evalDuration = evalDuration; }

    public Message getMessage() { return message; }
    public void setMessage(Message message) { this.message = message; }
}